package com.szt.mobile.inventory.modules.login.biz;

import android.util.Log;

import com.isoftstone.mis.ffair.util.log.FFLog;
import com.szt.mobile.inventory.common.constants.IntfConstants;
import com.szt.mobile.inventory.common.utils.FastJsonUtils;
import com.szt.mobile.inventory.common.utils.GsonUtil;
import com.szt.mobile.inventory.common.utils.Xutils;

import java.util.HashMap;

/**
 * Created by yanzhaodi on 2017/9/13.
 */
public class LoginBiz {
    public static void loginTest(Xutils xutils, Xutils.XCallBack callback) {
        HashMap<String, Object> map = new HashMap<>();
        HashMap<String, String> postdata = new HashMap<>();
        postdata.put("username", "test");
        postdata.put("password", "test");
        map.put("actioncode", "PDA001");
        map.put("GUID", System.currentTimeMillis() + "");
        map.put("postdata", postdata);
        String json = FastJsonUtils.getBeanToJson(map);
        xutils.post(IntfConstants.BASE_URL, json, callback);
    }

    public static void login(Xutils xutils, String username, String password, Xutils.XCallBack callback) {
        HashMap<String, Object> map = new HashMap<>();
        HashMap<String, String> postdata = new HashMap<>();
        postdata.put("username", username);
        postdata.put("password", password);
        map.put("actioncode", "PDA001");
        map.put("GUID", System.currentTimeMillis() + "");
        map.put("postdata", postdata);
        String json = FastJsonUtils.getBeanToJson(map);
        xutils.post(IntfConstants.BASE_URL, json, callback);
    }

    public static void loadAccount(Xutils xutils, Xutils.XCallBack callback) {
        try {
            HashMap<String, Object> postjson = new HashMap<>();
            postjson.put("actioncode", "PDA002");
            postjson.put("GUID", System.currentTimeMillis());
            HashMap<String, String> postData = new HashMap<>();
            postData.put("applyCode", "002");
            postData.put("wherestr", "");
            postjson.put("postdata", postData);
            String json = GsonUtil.GsonString(postjson);
            xutils.post(IntfConstants.BASE_URL, json, callback);
        } catch (Exception e) {
            FFLog.e(e, e.getMessage());
        }
    }

}
